package com.fbs.wowo.userBuy.service.imp;

import com.fbs.wowo.userBuy.entity.UserBuy;
import com.fbs.wowo.userBuy.mapper.UserBuyMapper;
import com.fbs.wowo.userBuy.service.UserBuyService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;


@Service
@Transactional
public class UserBuyServiceImp implements UserBuyService {

    @Resource
    private UserBuyMapper userBuyMapper;

    /**
     * 添加购买
     * @param record
     * @return
     */
    @Override
    public int insertSelective(UserBuy record) {
        record.setCreateDate(new Date());
        return userBuyMapper.insertSelective(record);
    }

    /**
     * 查询是否已购买
     * @param userId
     * @param buyId
     * @return
     */
    @Override
    public UserBuy selectByPrimaryKey(String userId, String buyId) {
        return userBuyMapper.selectByPrimaryKey(userId,buyId);
    }

    /**
     * 更新购买数据
     * @param record
     * @return
     */
    @Override
    public int updateByPrimaryKeySelective(UserBuy record) {
        return userBuyMapper.updateByPrimaryKeySelective(record);
    }
}
